﻿// IDib.h: interface for the IDib class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_IDIB_H__073F04B3_740A_4D9F_8678_68EE835C2AC7__INCLUDED_)
#define AFX_IDIB_H__073F04B3_740A_4D9F_8678_68EE835C2AC7__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "IKmUnknown.h"

class IProgressBar
{
};

typedef void (*LOAD_PROGRESS_CALLBACK)(LPVOID, int);

class IDib : public IKmUnknown
{
public:
	virtual BOOL Create(int nWidth, int nHeight, int nBitCount = 32) = 0;		// 创建
	virtual SIZE Size() = 0;								// 获取大小
	virtual int* GetBits(INT_PTR* pLength = NULL) = 0;			// 获取数据指针
	virtual CDC* BeginPaint(int iValue, BOOL bFillInit = true) = 0;				// 开始画(包含填充)
	virtual void EndPaint() = 0;							// 结束画
	virtual BOOL SaveToFile(LPCTSTR lpFileName) = 0;		// 把数据存入文件
	virtual void FillContent(int iValue) = 0;				// 以固定值填充
	virtual void Destroy () = 0;							// 销毁数据
	virtual void BitBlt( CDC* pDC, LPRECT lpRcDest, int xSrc = 0, int ySrc = 0, DWORD dwRop = SRCCOPY ) = 0; // 在屏幕上画

	virtual BOOL Erosion(BYTE* pS, int sl, void* pCopyToBits = NULL, IProgressBar* pBar = NULL) = 0;				// 腐蚀
	virtual BOOL Dilation(BYTE* pS, int sl) = 0;			// 膨胀
	virtual BOOL Open(BYTE* pS, int sl) = 0;				// 开运算
	virtual BOOL Close(BYTE* pS, int sl) = 0;				// 闭运算
	virtual BOOL Thining() = 0;								// 细化
	virtual void TransparentBlt( CDC* pDC, LPRECT lpRcDest, int xSrc = 0, int ySrc = 0) = 0; // 在屏幕上透明画

	virtual BOOL Contour() = 0;
	virtual BOOL LoadFromFile(LPCTSTR lpFileName) = 0;
	virtual int GetBitCount() = 0;

	virtual BOOL CreateFromBmpFile(CString& sFileName) = 0;
	virtual void StretchBlt( CDC* pDC, LPRECT lpRcDest, LPRECT lpRcSrc, DWORD dwRop = SRCCOPY ) = 0;
	virtual BOOL SaveToBmpFile(CString& sFileName) = 0;
	virtual void Mirror(BOOL bMirrorX, BOOL bMirrorY) = 0;

	virtual BOOL Serialize(CArchive& ar) = 0;
	virtual COLORREF Get8BitColor(int iIndex) = 0;
	virtual void Create8BitColor(COLORREF* pBasicCrs, int nNum) = 0;

	virtual BOOL SerializeJpg(CArchive& ar) = 0;
	virtual void Set8BitColor(int iIndex, COLORREF cr) = 0;
	virtual BOOL SaveToJPGFile(CString sFileName, int nQuality) = 0;

	virtual BOOL Copy(IDib* pSrc) = 0;

	virtual BOOL SavePartToFile(LPCTSTR lpFileName, int nRowCount) = 0;		// 把部分数据存入文件
	virtual BOOL LoadFromFile(CFile& file, int nRowCountPerTime = 0, LOAD_PROGRESS_CALLBACK lpCallback = NULL, LPVOID lpPara = NULL, int nBeginRow = 0) = 0;
	virtual BOOL CreateFromJPGFile(CString sFileName) = 0;
	virtual BOOL SavePartToFile2(LPCTSTR lpFileName, LPCTSTR lpFileName2, LPCTSTR lpFileName3, LPCTSTR lpFileName4, int nRowCount, int nSectionRowCount) = 0;		// 把部分数据存入文件
	virtual BOOL LoadFromFile2(LPCTSTR lpFileName, LPCTSTR lpFileName2, LPCTSTR lpFileName3, LPCTSTR lpFileName4, LOAD_PROGRESS_CALLBACK lpCallback = NULL, LPVOID lpPara = NULL, int nBeginRow = 0) = 0;
};

__declspec(dllexport) IDib* CreateIDib();
__declspec(dllexport) IDib* CreateINoPaintDib();

#endif // !defined(AFX_IDIB_H__073F04B3_740A_4D9F_8678_68EE835C2AC7__INCLUDED_)
